﻿@{
    Layout = null;
}
@*<div>奖池管理</div>*@

<script src="~/Scripts/MGJJS/Market/JackpotManage.js"></script>

<style>
    .myTabs.nav-tabs > li.active > a, .myTabs.nav-tabs > li.active > a:focus, .myTabs.nav-tabs > li.active > a:hover {
        color: #555;
        cursor: default;
        background-color: #fff;
        border: 1px solid #ddd;
        border-bottom-color: transparent;
    }
    .big .con-main {
        display: flex;
        align-items: flex-end;
        margin: 25px 0;
    }
        .big  p{
            margin:0;
        }
         .big .con-main div:nth-child(2) {
            flex: 1;
            margin: 0 20px;
        }

      .big .con-main div:nth-child(2) p {
                font-size: 15px;
            }
      .big .con-main .handle {
            margin-right: 40px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: space-around;
        }

        .big .con-main .handle div {
            width: 125px;
            line-height: 32px;
            text-align: center;
            background-color: #50AE55;
            color: white;
            border-radius: 5px;
        }
     .big .result-title {
        background-color: #F2F2F2;
        height: 46px;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-around;
    }

        .big .result-title span {
            flex: 1;
            text-align: center;
          
            font-size: 15px;
        }

           .big .result-title span:nth-child(1) {
                flex: 2;
            }

    .big .result-con {
        display: flex;
        align-items: center;
        margin: 15px 0;
    }

        .big .result-con > div.red-con {
            flex: 2;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }


            .big .result-con > div.red-con > div:nth-child(1) {
                padding: 10px 2px 10px 10px;
                background-color: #EE5F51;
                color: white;
                border-radius: 5px;
                margin-right: 20px;
                flex: 1;
            }


            .big .result-con > div.red-con > div:nth-child(2) {
               min-width:120px;
            }

                .big .result-con > div.red-con > div:nth-child(1) > p:nth-child(2) {
                    font-size: 30px;
                }

                    .big .result-con > div.red-con > div:nth-child(1) > p:nth-child(2) span {
                        font-size: 14px;
                    }

        .big .result-con > span, .big .result-con > a {
            flex: 1;
            text-align: center;
        }

</style>

<div class="mtlr15" data-example-id="togglable-tabs">
    <ul class="myTabs nav nav-tabs" role="tablist" style="display:flex;align-items:center">
        @*<li role="presentation" class="">
            <a href="#Coupon" id="Coupon-tab" role="tab" data-toggle="tab" aria-controls="Coupon" aria-expanded="true">优惠券</a>
        </li>*@
        <li role="presentation" class="active">
            <a href="#RedPackage" role="tab" id="RedPackage-tab" data-toggle="tab" aria-controls="RedPackage" aria-expanded="false">红包</a>
        </li>
        <li role="presentation" class="">
            <a href="#Flow" role="tab" id="Flow-tab" data-toggle="tab" aria-controls="Flow" aria-expanded="false">流量</a>
        </li>
        <li style="flex:1"></li>
        <li style="width:400px;">
            <div class="input-group">
 
                <input id="Search" type="text" class="form-control" placeholder="奖品名称" onkeydown="if (event.keyCode == 13) { $.MGJ.JackpotManage.JackpotTable(3, 1); }">
 
 
                <span class="input-group-addon">
                    <span  class="glyphicon glyphicon-search" onclick="$.MGJ.JackpotManage.JackpotTable(3, 1);"></span>
                </span>
                @*<div class="input-group-btn" style="margin-left:1px;">
                    <button type="button" class="btn btn-default" style="border: 1px solid transparent;">
                        更多搜索
                        <span class="caret"></span>
                    </button>
                </div>*@
            </div>
        </li>
    </ul>
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane fade  in" aria-labelledby="Coupon-tab"   id="Coupon">
            <!--优惠券表格数据-->
            <div class="big" id="YHJDate">
                <div class="con-main">
                    <img src="~/Content/webImgs/Market/CreateActivities/3.png" />
                    <div>
                        <p>优惠券 <a href="" style="color: #EE5F51; text-decoration: none">(查看使用说明规则)</a></p>
                        <p>按优惠券规则进行交易下单页面直接抵扣（支付方式有微信、支付宝、商城等）</p>
                        <p style="width: 100%;height: 16px"></p>
                        @*<p>30天累计送出： <span style="color: #EE5F51;">￥ 0.00元</span></p>*@

                        <p class="send">
                            今日送出： <span style="color: #EE5F51;" id="dayYHJSend">￥ 0.00元</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当月累计送出：
                            <span id="monthYHJSend" style="color: #EE5F51;">￥0.00元</span>
                        </p>
                    </div>
                    <div class="handle">
                        <a class="btn btn-success" onclick="$.MGJ.JackpotManage.Dialog_CreateCoupon()">
                            创建优惠券模板
                        </a>
                    </div>
                </div>

                <div class="result-title">
                    <span>优惠券</span>
                    <span>使用条件</span>
                    <span>截止日期</span>
                    <span>备注</span>
                    <span>管理</span>
                </div>
            </div>
        </div>
        <div role="tabpanel" class="tab-pane fade active in" id="RedPackage" aria-labelledby="RedPackage-tab">
            <!--红包表格数据-->
            <div class="big" id="redPacketData">
                <div class="con-main">
                    <img src="~/Content/webImgs/Market/CreateActivities/2.png" alt="null">
                    <div>
                        <p>红包 <a href="" style="color: #EE5F51; text-decoration: none">(查看使用说明规则)</a></p>
                        <p>支持在交易下单页面直接抵扣（支付方式有微信、支付宝、商城等）</p>
                        <p style="width: 100%;height: 16px"></p>
                        <p class="send">
                            今日送出： <span style="color: #EE5F51;" id="dayRPSend">￥ 0.00元</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 当月累计送出：
                            <span id="monthRPSend" style="color: #EE5F51;">￥ 0.00元</span>
                        </p>
                    </div>
                    <div class="handle">
                       
                        <a class="btn btn-success" onclick="$.MGJ.JackpotManage.Dialog_CreateRP()">
                            创建红包模板
                        </a>
                    </div>
                </div>
                <div class="result-title">
                    <span>红包</span>
                    <span>数量</span>
                    <span>金额</span>
                    <span>备注</span>
                    <span>操作</span>
                </div>
                <div class="result-con">
                   
                </div>
              
            </div>

        </div>
        <div role="tabpanel" class="tab-pane fade  in" id="Flow" aria-labelledby="Flow-tab">
            <!--流量包表格数据-->
            <div class="big" id="LLBDate">
                <div class="con-main">
                    <img src="~/Content/webImgs/Market/CreateActivities/1.png" alt="null" >
                    <div>
                        <p>流量包 <a href="" style="color: #EE5F51; text-decoration: none">(查看使用说明规则)</a></p>
                        <p>全网通用支持移动、联通、电信</p>
                        <p style="width: 100%;height: 16px"></p>
                        <p class="send">
                            今日送出： <span style="color: #EE5F51;" id="dayLLBSend">0M</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 30天累计送出：
                            <span style="color: #EE5F51;">0M</span>
                        </p>
                    </div>
                    <div class="handle">
                        <a class="btn btn-success" style="margin-bottom: 20px;padding:4px 33px;display:none;" onclick="$.MGJ.Common.loadurl(this, '/Market/FlowRecharge')">
                            流量充值
                        </a>
                        <a class="btn btn-success" onclick="$.MGJ.JackpotManage.Dialog_CreateFlow()">
                            创建流量包模板
                        </a>
                    </div>
                </div>
                <div class="result-title">
                    <span>流量包</span>
                    <span>数量</span>
                    <span>流量</span>
                    <span>备注</span>
                    <span>操作</span>
                </div>
                <div class="result-con"></div>
              
            </div>
        </div>

    </div>
</div>

<script>
    //授权  id：授权的奖池id
   function Ajax_Accredit(id)
    {
        $.L.ajaxHandle({
            url:"/Market/Accredit"  ,
            data: { ID: id },
            success: function (data) {
                //console.log(data);
                //color: #EE5F51 hong
                //color: #50AE55
         
                if (data.b) {
                    $.L.msgSuccess("操作成功！");
                    if (data.flag == 0) {
                        $("#" + id + " .flag").text("未授权").attr("style", "color:#EE5F51");
                        $("#" + id + " .empower").text("立即授权").attr("style", "color:#50AE55");
                    }
                    else{
                        $("#" + id + " .flag").text("已启用").attr("style", "color:#50AE55");
                        $("#" + id + " .empower").text("立即禁用").attr("style", "color:#EE5F51");
                    }
                
                }
                else  
                    $.L.msgError("操作失败！ 该奖品数量少于0！");

            }
        });
    } 

    //格式化时间戳
    function getLocalTime(nS) {
        //return new Date(parseInt(nS)).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ").replace(/上午|下午/g, " ");
        return new Date(parseInt(nS)).toLocaleDateString();//转换成年月日
    }
    var psize = 3;//一页显示的数量
    var pid = 1;//起始页
    //加载表格数据    type:传1 红包数据 传：2 优惠券  传3：流量包
    //初始化时加载红包数据
    $.MGJ.JackpotManage.JackpotTable(psize, 1);
    $('.myTabs a[data-toggle="tab"][role="tab"]').on('shown.bs.tab', function (e) {
        //console.log(e.target)  // newly activated tab   //console.log(e.relatedTarget)  //previous active tab
        if ($(e.target).text() === "优惠券")
        {
            $("#YHJDate .result-con").remove();
            $('#YHJDate .more').remove();
            GetJackpotSendNum(2)
            psize = 3;//一页显示的数量
            $.MGJ.JackpotManage.JackpotTable(psize, 2); 
        }
        else if ($(e.target).text() === "红包") {
            $("#redPacketData .result-con").remove();
            $('#redPacketData .more').remove();
            GetJackpotSendNum(1)
            psize = 3;//一页显示的数量
            $.MGJ.JackpotManage.JackpotTable(psize, 1);
        }
        else { 
            $("#LLBDate .result-con").remove();
            $('#LLBDate .more').remove();
            psize = 3;//一页显示的数量
            $.MGJ.JackpotManage.JackpotTable(psize, 3);
            GetJackpotSendNum(3);
        }
    })          
    function GetJackpotSendNum(Type) {
        $.ajax({
            type: "post",
            url: '/Market/GetJackpotSendNum',
            data: { type: Type },
            success: function (data) {
                if (Type==1)//红包
                {
                    var dayMoney = data.dayMoney == "" ? "0.00" : data.dayMoney;
                    var monthMoney = data.monthMoney == "" ? "0.00" : data.monthMoney;
                    $('#redPacketData .send #dayRPSend').text("￥" + dayMoney + "元").next('span').text("￥" + monthMoney + "元");
                }
                else if (Type == 2)//优惠券
                {
                    var dayMoney = data.dayMoney == "" ? "0.00" : data.dayMoney;
                    var monthMoney = data.monthMoney == "" ? "0.00" : data.monthMoney;
                    $('#YHJDate .send #dayYHJSend').text("￥" + dayMoney + "元").next('span').text("￥" + monthMoney + "元");
                }
                else {//流量
                    var dayMoney = data.dayMoney == "" ? "0.00" : data.dayMoney;
                    var monthMoney = data.monthMoney == "" ? "0.00" : data.monthMoney;
                    $('#LLBDate .send #dayLLBSend').text(dayMoney + "M").next('span').text(monthMoney + "M");
                }
            }
        })
    }
    GetJackpotSendNum(1);
</script>